<?php
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT'].'/');
$path = ROOT_DIR.'setting.php';
$settingsContent = file_get_contents($path);
$api_authcode_human_open = $_POST['api_authcode_human_open'];
$api_authcode_human_url = $_POST['api_authcode_human_url'];
$api_authcode_human_key = $_POST['api_authcode_human_key'];
$api_authcode_human_secret = $_POST['api_authcode_human_secret'];
$newSettingMailArray = <<<EOT
\$api_authcode_human = array(   //实名认证(二要素)推荐https://market.cloud.tencent.com/products/5290
    'api_authcode_human_open' => '$api_authcode_human_open', //是否开启实名认证
    'api_authcode_human_url' => '$api_authcode_human_url', //API站点
    'api_authcode_human_key' => '$api_authcode_human_key', //KEY
    'api_authcode_human_secret' => '$api_authcode_human_secret', //Secret
);
EOT;
$pattern = '/\$api_authcode_human = array\(.*?\);/s';
$replacement = $newSettingMailArray;
$updatedSettingsContent = preg_replace($pattern, $replacement, $settingsContent);
file_put_contents($path, $updatedSettingsContent);
echo '<script>alert("修改成功");window.location.href="../../pluginset.php?s=smrz";</script>';